﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Microsoft.Kinect;

namespace Final_Project
{
    class CDepthFileReader
    {
        private string m_strPath;

        public CDepthFileReader(string strPath)
        {
            m_strPath = strPath;
        }

        public void ReadDepthMapFromFile(DepthImagePixel[] values, uint unIndex)
        {
            String[] DataFromFile;

            try
            {
                using (StreamReader sr = new StreamReader(m_strPath + unIndex))
                {
                    String line = sr.ReadToEnd();
                    DataFromFile = line.Split(' ');

                    for (int i = 0; i < DataFromFile.Length - 1; i++)
                    {
                        values[i].Depth = Convert.ToInt16(DataFromFile[i]);
                    }
                }
            }
            catch (Exception e)
            {
                System.Console.WriteLine("File doesn't exist.\n");
            }
        } // ReadDepthMapFromFile

        public void ReadDepthMapFromFile(short[] values, uint unIndex)
        {
            String[] DataFromFile;

            try
            {
                using (StreamReader sr = new StreamReader(m_strPath + unIndex))
                {
                    String line = sr.ReadToEnd();
                    DataFromFile = line.Split(' ');

                    for (int i = 0; i < DataFromFile.Length - 1; i++)
                    {
                        values[i] = Convert.ToInt16(DataFromFile[i]);
                    }
                }
            }
            catch (Exception e)
            {
                System.Console.WriteLine("File doesn't exist.\n");
            }
        } // ReadDepthMapFromFile
    }
}




